﻿using Modules.System.Menu;
using PetaPoco;
using PmSoft;
using PmSoft.Caching;
using SqlSugar;
using System.ComponentModel;
using static Modules.Project.ProjectConstants;

namespace Modules.System.Dept
{
    /// <summary>
    /// 主管单位表
    ///</summary>
    [TableName("sys_dept")]
    [Description("主管单位信息表")]
    [PrimaryKey("dept_id", AutoIncrement = true)]
    [CacheSetting(true, PropertyNamesOfArea = "IndustryType")]
    [Serializable]
    public class SysDept : IDelEntity
    {
        /// <summary>
        /// 主键
        ///</summary>
        [Column("dept_id")]
        public int DeptId { get; set; }

        /// <summary>
        /// 行业分类
        /// </summary>
        [Column("industry_type")]
        public 行业主管部门 IndustryType { get; set; }

        /// <summary>
        /// 主管单位名称
        ///</summary>
        [Column("name")]
        public string Name { get; set; }

        /// <summary>
        /// 组织机构代码
        ///</summary>
        [Column("code")]
        public string Code { get; set; }

        /// <summary>
        /// 归属省代码
        ///</summary>
        [Column("province_code")]
        public int? ProvinceCode { get; set; }

        /// <summary>
        /// 归属地市代码
        ///</summary>
        [Column("city_code")]
        public int? CityCode { get; set; }

        /// <summary>
        /// 归属区县代码
        ///</summary>
        [Column("area_code")]
        public int? AreaCode { get; set; }

        /// <summary>
        /// 行政级别 1：部、2：省、3：市、4：县
        ///</summary>
        [Column("level")]
        public AdministrativeLevel Level { get; set; }

        /// <summary>
        /// 创建时间
        /// 默认值: CURRENT_TIMESTAMP
        ///</summary>
        [Column("create_time")]
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 是否系统保留，无法删除
        /// 默认值: b'0'
        ///</summary>
        [Column("is_deleted")]
        public bool IsDeleted { get; set; }

        #region IEntity 成员

        [Ignore]
        object IEntity.EntityId { get { return DeptId; } }

        [Ignore]
        bool IDelEntity.IsDeletedInDatabase { get => IsDeleted; set => IsDeleted = value; }

        #endregion IEntity 成员
    }

    /// <summary>
    /// 主管单位表
    ///</summary>
    [SugarTable("sys_dept")]
    public class SysDeptSugar 
    {
        /// <summary>
        /// 主键
        ///</summary>
        [SugarColumn(ColumnName = "dept_id", IsPrimaryKey = true, IsIdentity = true)]
        public int DeptId { get; set; }

        /// <summary>
        /// 行业分类
        /// </summary>
        [SugarColumn(ColumnName = "industry_type")]
        public 行业主管部门 IndustryType { get; set; }

        /// <summary>
        /// 主管单位名称
        ///</summary>
        [SugarColumn(ColumnName = "name")]
        public string Name { get; set; }

        /// <summary>
        /// 组织机构代码
        ///</summary>
        [SugarColumn(ColumnName = "code")]
        public string Code { get; set; }

        /// <summary>
        /// 归属省代码
        ///</summary>
        [SugarColumn(ColumnName = "province_code")]
        public int? ProvinceCode { get; set; }

        /// <summary>
        /// 归属地市代码
        ///</summary>
        [SugarColumn(ColumnName = "city_code")]
        public int? CityCode { get; set; }

        /// <summary>
        /// 归属区县代码
        ///</summary>
        [SugarColumn(ColumnName = "area_code")]
        public int? AreaCode { get; set; }

        /// <summary>
        /// 行政级别 1：部、2：省、3：市、4：县
        ///</summary>
        [SugarColumn(ColumnName = "level")]
        public AdministrativeLevel Level { get; set; }

        /// <summary>
        /// 创建时间
        /// 默认值: CURRENT_TIMESTAMP
        ///</summary>
        [SugarColumn(ColumnName = "create_time")]
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 是否系统保留，无法删除
        /// 默认值: b'0'
        ///</summary>
        [SugarColumn(ColumnName = "is_deleted")]
        public bool IsDeleted { get; set; }

    }
}